package edu.ccut.saturn.component.impl;

import edu.ccut.saturn.component.IWebContextValueInfo;
import edu.ccut.saturn.component.impl.node.WebContextNodeInfo;
import edu.ccut.saturn.component.loader.node.WebContextNodeInfoLoader;
import edu.ccut.saturn.component.xml.ISaturnElement;
import edu.ccut.saturn.component.xml.SaturnElement;

/**
 * 网页上下文结点中的上下文转换信息的实现类，实现了接口<code>IWebContextValueInfo</code>。
 * 
 * @author 温建
 * @version 1.0 2008.9.05
 * @see WebContextNodeInfo
 */
public class WebContextValueInfo implements IWebContextValueInfo {

	private String id = null;

	private String key = null;

	private String scope = null;

	private String newKey = null;

	private String newScope = null;

	private String isDelete = null;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getScope() {
		return scope;
	}

	public void setScope(String scope) {
		this.scope = scope;
	}

	public String getNewKey() {
		return newKey;
	}

	public void setNewKey(String newKey) {
		this.newKey = newKey;
	}

	public String getNewScope() {
		return newScope;
	}

	public void setNewScope(String newScope) {
		this.newScope = newScope;
	}

	public String getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(String isDelete) {
		this.isDelete = isDelete;
	}

	public WebContextValueInfo(String id, String key, String scope,
			String newKey, String newScope, String isDelete) {

		this.id = id;
		this.key = key;
		this.scope = scope;
		this.newKey = newKey;
		this.newScope = newScope;
		this.isDelete = isDelete;
	}

	public ISaturnElement toSaturnElement() {
		ISaturnElement element = new SaturnElement(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE);

		element.addAttribute(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_ID, this.id);

		element.addAttribute(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_ISDELETE,
				this.isDelete);

		element
				.addAttribute(
						WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_KEY,
						this.key);

		element.addAttribute(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_NEWKEY,
				this.newKey);

		element.addAttribute(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_NEWSCOPE,
				this.newScope);

		element.addAttribute(
				WebContextNodeInfoLoader.KEY_WEBCONTEXT_VALUEMOVE_SCOPE,
				this.scope);

		return element;
	}

	public String toXmlStr() {
		ISaturnElement saturnElement = toSaturnElement();
		return saturnElement.getXMLStr();
	}
}
